package test;

import java.util.*;

public class Main{
    
    static final int INF = (int)1e9;
    
    static int[] a;
    static int[][] tree;
    
    static int[] merge(int[] tree1, int[] tree2) {
        int[] res = new int[8];
        int l = 0, r = 0;
        for (int i = 0; i < 8; i++) {
            if (tree1[l] >= tree2[r]) {
                res[i] = tree1[l++];
            } else {
                res[i] = tree2[r++];
            }
        }
        return res;
    }
    
    static int ls(int p) { return p << 1; }
    static int rs(int p) { return p << 1 | 1; }
    static void push_up(int p) {
        tree[p] = merge(tree[ls(p)], tree[rs(p)]);
    }
    static void build(int p, int pl, int pr) {
        if (pl == pr) {
            tree[p][0] = a[pl];
            return;
        }
        int mid = (pl + pr) / 2;
        build(ls(p), pl, mid);
        build(rs(p), mid + 1, pr);
        push_up(p);
    }
    static void update(int p, int pl, int pr, int l, int r, int d) {
        if (l <= pl && pr <= r) {
            tree[p][0] = d;
            return;
        }
        int mid = (pl + pr) / 2;
        if (l <= mid) {
            update(ls(p), pl, mid, l, r, d);
        }
        if (mid < r) {
            update(rs(p), mid + 1, pr, l, r, d);
        }
        push_up(p);
    }
    static int[] query(int p, int pl, int pr, int l, int r) {
        if (l <= pl && pr <= r) {
            return tree[p];
        }
        int[] res = new int[8];
        int mid = (pl + pr) / 2;
        if (l <= mid) {
            res = merge(res, query(ls(p), pl, mid, l, r));
        }
        if (mid < r) {
            res = merge(res, query(rs(p), mid + 1, pr, l, r));
        }
        return res;
    }
    
    public static void main(String[] args) {
        // 长度限制，省略非关键写法，请读者自行完善
    	Scanner sc = new Scanner(System.in);
    	
    	String[] strs = sc.nextLine().split(" ");
    	
    	int n = Integer.parseInt(strs[0]);
    	int num = Integer.parseInt(strs[1]);
    	
    	a = new int[n + 1];
        tree = new int[n << 2][8];
        build(1, 1, n);
    	
    	for(int i=0;i<num;i++) {
    		strs = sc.nextLine().split(" ");
    		int n1 = Integer.parseInt(strs[1]);
    		int n2 = Integer.parseInt(strs[2]);
    		if(strs[0].charAt(0)=='C') {
    			update(1, 1, n, n1, n1, n2);
    		}else {
    			int[] res = query(1, 1, n, n1, n2);
    			System.out.println(res[7]);
    		}
    	}
    	
        

    }
}